library("xts")
library("rredis")

redisConnect()
l <- 50
t1 <- Sys.time()
redisIncrBy("count",0)
x0 <- as.numeric(redisGet("count"))
r <- as.xts(0,order.by=t1)
while(TRUE) {
  Sys.sleep(2)
  x <- as.numeric(redisGet("count"))
  t2 <- Sys.time()
  d <- (x-x0)/(difftime(t2,t1,units="secs")[[1]])
  r <- rbind(r, as.xts(d, order.by=t2))
  t1 <- t2
  x0 <- x
  if(nrow(r)>1) r <- r[(nrow(r)-1):nrow(r),]
  plot(as.zoo(r), type="l", lwd=2, col=4, ylab="Tasks/second", xlab="Time")
}
